<div class="col-md-2">
    <div class="actions">
        <h2><kbd><?php echo __('Actions'); ?></kbd></h2>
        <hr/>
        <ul class="nav nav-stacked">
            <li><?php echo $this->Html->link(__('New User'), array('action' => 'add')); ?></li>
            <li><?php echo $this->Html->link(__('List Categories'), array('controller' => 'categories', 'action' => 'index')); ?> </li>
            <li><?php echo $this->Html->link(__('New Category'), array('controller' => 'categories', 'action' => 'add')); ?> </li>
            <li><?php echo $this->Html->link(__('List Wallets'), array('controller' => 'wallets', 'action' => 'index')); ?> </li>
            <li><?php echo $this->Html->link(__('New Wallet'), array('controller' => 'wallets', 'action' => 'add')); ?> </li>
            <li><?php echo $this->Html->link(__('List Transactions'), array('controller' => 'transactions', 'action' => 'index')); ?> </li>
        </ul>
    </div>
</div>

<div class="col-md-10">
    <h2><kbd><?php echo __('Users'); ?></kbd></h2>
    <hr/>
    <table class="table table-bordered">
        <tr class="success">
            <th><?php echo $this->Paginator->sort('username'); ?></th>
            <th><?php echo $this->Paginator->sort('email'); ?></th>
            <th><?php echo $this->Paginator->sort('last_access'); ?></th>
            <th class="actions"><?php echo __('Actions'); ?></th>
        </tr>
        <?php foreach ($profiles as $profile): ?>
            <tr>
                <td><a class="text-center" data-toggle="modal" href="#myModal<?php echo $profile['pr']['users_id']; ?>"
                        ><?php echo $profile['u']['username'] ?>
                        <img src="/money/uploads/<?php echo $profile['pr']['avatar']; ?>" class="img-circle pull-right" width="40px" height="40px" alt="avatar"/></a></td>
                <td><?php echo h($profile['u']['email']); ?>&nbsp;</td>
                <td><?php echo h($profile['u']['last_access']); ?>&nbsp;</td>
                <td class="actions">

                    <?php if ($currentUser['id'] == 20): ?>
                        <?php echo $this->Html->link(__('View'), array('action' => 'view', $profile['pr']['users_id']), array('class' => 'btn-sm btn-info')); ?>
                        <?php echo $this->Html->link(__('Edit'), array('action' => 'edit', $profile['pr']['users_id']), array('class' => 'btn-sm btn-warning')); ?>
                        <?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $profile['pr']['users_id']), array('class' => 'btn-sm btn-danger'), __('Are you sure you want to delete # %s?', $profile['pr']['users_id'])); ?>
                    <?php elseif ($currentUser['id'] == $profile['pr']['users_id']): ?>
                        <?php echo $this->Html->link(__('View'), array('action' => 'view', $profile['pr']['users_id']), array('class' => 'btn-sm btn-info')); ?>
                        <?php echo $this->Html->link(__('Edit'), array('action' => 'edit', $profile['pr']['users_id']), array('class' => 'btn-sm btn-warning')); ?>
                    <?php
                    else: ?>
                        <?php echo $this->Html->link(__('View'), array('action' => 'view', $profile['pr']['users_id']), array('class' => 'btn-sm btn-info')); ?>
                    <?php endif; ?>
                </td>
            </tr>
            <!-- Modal -->
            <div class="modal fade" id="myModal<?php echo $profile['u']['id'] ?>" tabindex="-1" role="dialog"
                 aria-labelledby="myModalLabel"
                 aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"
                                    aria-hidden="true">&times;</button>
                            <h4 class="modal-title"><?php echo $profile['u']['username'] ?></h4>
                        </div>
                        <div class="modal-body">
                            <div class="row">
                                <div class="col-md-4">
                                    <img src="/money/uploads/<?php echo $profile['pr']['avatar']; ?>"
                                         class="img-thumbnail" alt="avatar"/>
                                </div>

                                <div class="caption col-md-8">
                                    <h4>Email: <span class="text-info"><?php echo $profile['u']['email'] ?></span></h4>

                                    <p>Gender: <span class="text-warning"><?php echo $profile['pr']['gender']; ?></span>
                                    </p>

                                    <p>Address: <span
                                            class="text-warning"><?php echo $profile['pr']['address']; ?></span>
                                    </p>

                                    <p>Phone: <span class="text-warning"><?php echo $profile['pr']['phone']; ?></span>
                                    </p>

                                    <p>Birth day:<span
                                            class="text-warning"><?php echo $profile['pr']['birthday']; ?></span>
                                    </p>
                                </div>

                            </div>
                        </div>
                        <div class="modal-footer">
                            <?php if ($profile['u']['id'] == $currentUser['id']): ?>
                                <?php echo $this->Html->link('Update Profile', array('controller' => 'profiles', 'action' => 'edit', $profile['u']['id']), array('class' => 'btn btn-sm btn-primary')) ?>
                            <?php endif; ?>
                        </div>

                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
            <!-- /.modal -->

        <?php endforeach; ?>
    </table>

    <p>
        <?php
        echo $this->Paginator->counter(array(
            'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
        ));
        ?>    </p>

    <ul class="pagination">
        <?php
        echo '<li>' . $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled')) . '</li>';
        echo '<li>' . $this->Paginator->numbers(array('separator' => '')) . '</li>';
        echo '<li>' . $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled')) . '</li>';
        ?>
    </ul>
</div>

